package com.ruoyi.parcel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.parcel.domain.EPaymentOrder;
import com.ruoyi.parcel.service.IEPaymentOrderService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * orderController
 *
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/parcel/order")
public class EPaymentOrderController extends BaseController
{
    @Autowired
    private IEPaymentOrderService ePaymentOrderService;

    /**
     * 查询order列表
     */
    @RequiresPermissions("parcel:order:list")
    @GetMapping("/list")
    public TableDataInfo list(EPaymentOrder ePaymentOrder)
    {
        startPage();
        List<EPaymentOrder> list = ePaymentOrderService.selectEPaymentOrderList(ePaymentOrder);
        return getDataTable(list);
    }

    /**
     * 导出order列表
     */
    @RequiresPermissions("parcel:order:export")
    @Log(title = "order", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EPaymentOrder ePaymentOrder)
    {
        List<EPaymentOrder> list = ePaymentOrderService.selectEPaymentOrderList(ePaymentOrder);
        ExcelUtil<EPaymentOrder> util = new ExcelUtil<EPaymentOrder>(EPaymentOrder.class);
        util.exportExcel(response, list, "order数据");
    }

    /**
     * 获取order详细信息
     */
    @RequiresPermissions("parcel:order:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ePaymentOrderService.selectEPaymentOrderById(id));
    }

    /**
     * 新增order
     */
    @RequiresPermissions("parcel:order:add")
    @Log(title = "order", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EPaymentOrder ePaymentOrder)
    {
        return toAjax(ePaymentOrderService.insertEPaymentOrder(ePaymentOrder));
    }

    /**
     * 修改order
     */
    @RequiresPermissions("parcel:order:edit")
    @Log(title = "order", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EPaymentOrder ePaymentOrder)
    {
        return toAjax(ePaymentOrderService.updateEPaymentOrder(ePaymentOrder));
    }

    /**
     * 删除order
     */
    @RequiresPermissions("parcel:order:remove")
    @Log(title = "order", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ePaymentOrderService.deleteEPaymentOrderByIds(ids));
    }
    @Log(title = "order", businessType = BusinessType.DELETE)
	@PostMapping("/orderNumber/{orderNumber}")
    public EPaymentOrder getzhifu(@PathVariable Long orderNumber)
    {
        EPaymentOrder patment = ePaymentOrderService.getPatment(orderNumber);
        System.out.println(patment);
        return patment;
    }
}
